﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Reflection;
using System.Security.Cryptography;

namespace NBusiness.Utilities
{
    public static class Extensions
    {
        public static byte[] PublicKeyToken(this Type type)
        {
            byte[] hash = type.Assembly.GetName().GetPublicKey();
            byte[] publicKeyToken = null;

            if (hash.Length > 0)
            {
                publicKeyToken = new byte[8];
                Array.Copy(hash, hash.Length - publicKeyToken.Length, publicKeyToken, 0, publicKeyToken.Length);
                Array.Reverse(publicKeyToken, 0, publicKeyToken.Length);
            }
            return publicKeyToken;
        }
    }
}
